<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>WebFlux SSE Subscribe Example</title>
</head>
<body>
    <div id="messages"></div>
    <script>
        const eventSource = new EventSource('/sse/subscribe');
        const messagesDiv = document.getElementById('messages');

        eventSource.onmessage = function (event) {
            const newMessage = document.createElement('p');
            newMessage.textContent = `Received: ${event.data}`;
            messagesDiv.appendChild(newMessage);
        };

        eventSource.onerror = function (error) {
            console.error('EventSource failed:', error);
            eventSource.close();
        };

    </script>
</body>
</html>    